package keke;

import java.util.*;

abstract class Shape {
	public static double PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
}

class Rectangle extends Shape{
	private int width;
	private int length;
	
	public Rectangle(int width,int length){
	this.width=width;
	this.length=length;
	}
	
@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}

	public double getPerimeter(){	
		return (width+length)*2;
	}
	
	public double getArea(){	
		return width*length;
	}

}
class Circle extends Shape{
	private int radius;
	
	public Circle(int radius){
	this.radius=radius;
	}
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
	public double getPerimeter(){
		return 2*radius*Shape.PI;
	}
	
	public double getArea(){	
		return radius*radius*Shape.PI;
	}

}

public class Main0304 {
	public static double sumAllArea(Shape[] shape){
		double Area = 0;
		for (int i = 0; i < shape.length; i++) {
			Area += shape[i].getArea();
		}
		return Area;
	}
		
	public static double sumAllPerimeter(Shape[] shape){
		double Perimeter = 0;
		for(int j=0;j<shape.length;j++){
			Perimeter+=shape[j].getPerimeter();
		}
		return Perimeter;
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		Shape[] shape=new Shape[n];
		for(int k=0;k<n;k++){
			String str=in.next();
			if(str.equals("rect")){
				shape[k]=new Rectangle(in.nextInt(),in.nextInt());
			}
			else if(str.equals("cir")){
				shape[k]=new Circle(in.nextInt());
			}
		}
        System.out.println(sumAllPerimeter(shape));
        System.out.println(sumAllArea(shape));
        System.out.println(Arrays.toString(shape));
        for(int m=0;m<n;m++){
        	System.out.println(shape[m].getClass()+","+shape[m].getClass().getSuperclass());
        	}
        }
}


